package com.atguigu.tingshu.order.pattern.factory;

import com.atguigu.tingshu.order.pattern.strategy.TradeOrderStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author: atguigu
 * @create: 2025-03-25 16:23
 */
@Component
public class TradeOrderStrategyFactory {

    @Autowired
    private Map<String, TradeOrderStrategy> tradeOrderStrategyMap;


    /**
     * 根据商品类别返回策略实现类对象
     * @param type
     * @return
     */
    public TradeOrderStrategy getTradeOrderStrategy(String type) {
        return tradeOrderStrategyMap.get(type);
    }
}
